/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package ControladoresUI;

import Entidades.Gradoacademico;
import Entidades.Usuario;
import Ingresos.ICatedratico;
import Ingresos.IGradoAcademico;
import ManagersUI.CatedraticoRegistroManager;
import java.util.logging.Level;
import java.util.logging.Logger;
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.scene.control.Button;
import javafx.scene.control.ComboBox;
import javafx.scene.control.TextField;
import javax.swing.JOptionPane;

/**
 *
 * @author Carlos Andy T. Tiniguar <Tini0106Andy@gmail.com>
 */
public class CatedraticoRegistroController {
    Usuario usuario; 
    CatedraticoRegistroManager catedraticoRegistroManager;
    @FXML private TextField txtNombres;
    @FXML private TextField txtApellidos;
    @FXML private TextField txtTelefono;
    @FXML private TextField txtCreditos;
    @FXML private TextField txtSueldo;
    @FXML private TextField txtNoCatedratico;
    @FXML private ComboBox cmbGradoAcademico;  
    
    public void initialize() {}
  
    public void initManager(final CatedraticoRegistroManager catedraticoRegistroManager,Usuario usuario) {
        this.catedraticoRegistroManager = catedraticoRegistroManager;
        this.usuario = usuario;
        cargarGradoAcademico();
    }
    public void cargarGradoAcademico(){
        this.cmbGradoAcademico.setPromptText("Grado Academico");
         IGradoAcademico manejo = new IGradoAcademico();
        this.cmbGradoAcademico.getItems().clear();
        this.cmbGradoAcademico.getItems().addAll(manejo.mostrarTodo());
       //this.cmbCatedratico
    }
    @FXML
    private void RegresarInicio(ActionEvent event){
       catedraticoRegistroManager.showPnlCatedraticoInicio(usuario);
    }
    @FXML
    private void AgregarCatedratico(ActionEvent event){
        try {
            ICatedratico nuevo = new ICatedratico();
            nuevo.guardar(Integer.parseInt(this.txtNoCatedratico.getText()),txtNombres.getText(), txtApellidos.getText(), txtTelefono.getText(), Short.parseShort(txtCreditos.getText()),Float.parseFloat(this.txtSueldo.getText()),(Gradoacademico)this.cmbGradoAcademico.getValue());
            JOptionPane.showMessageDialog( null, "Ingresado exitosamente","Mensaje", JOptionPane.INFORMATION_MESSAGE );
            catedraticoRegistroManager.showPnlCatedraticoInicio(usuario);
        } catch (Exception ex) {
            Logger.getLogger(CatedraticoRegistroController.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
    
}
